<% crlf=CHR(13)+CHR(10) SET CENTURY ON m_transid=orequest.form('thetransid') if isnull(m_transid) m_transid=orequest.querystring('t') endif theuser=orequest.querystring('user') if isnull(m_transid) tsql=[select top 1 *,IIF(VAL(transid)=0,VAL(SUBSTR(transid,2)),VAL(transid)) AS VTR, ] tsql=tsql+[ padl(allt(transid),9) as ptransid ] tsql=tsql+[ from ("]+dbclocation+'cashsale.dbf'+[") order by vtr desc, ptransid desc ] else tsql=[select top 1 *,IIF(VAL(transid)=0,VAL(SUBSTR(transid,2)),VAL(transid)) AS VTR, ] tsql=tsql+[ padl(allt(transid),9) as ptransid ] tsql=tsql+[ from ("]+dbclocation+'cashsale.dbf'+[") order by vtr desc, ptransid desc where allt(transid)==']+allt(m_transid)+['] endif &tsql SCATTER NAME SearchResults if TYPE('SearchResults.fbrinv')='C' and not ALLTRIM(SearchResults.fbrinv)=='0' and not EMPTY(SearchResults.fbrinv) fbrnumberreceived=allt(searchresults.fbrinv) else fbrnumberreceived=[] endif if empty(date) thedatestring=date() &&transform(date()) else thedatestring=date &&transform(dtoc(date)) endif openingbalance=[] if BETWEEN(val(left(SearchResults.depositid,2)),1,8) and left(SearchResults.depositid,3)<>'019' select sum(debit-credit) as dayopening from (dbclocation+[acctran]) where accountid=SearchResults.depositid and date]+ALLTRIM(accounts.name)+[] =SEEK(SearchResults.depositid,[accounts],[accountid]) cdebitor=[] invnum=searchresults.transid CLOSE TABLES CLOSE DATABASES ************* USE IN SELECT('printinvoice') IF NOT EMPTY(xcompany.fbrposid) Select d.name as deposited,x.depositid, x.Total As PrdTotal, x.fbrinv, x.fbrPOST, x.daysrno, x.discount As prdDisc, x.memdisc,; A.TAXPRATE, A.TAXRATE, x.Payment,; x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill,; x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer,z.SaleMan As ySaleMan,Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ; z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,z.bonus,z.rate,a.cost, a.trade ,x.dtime,x.srvchgs, z.discount, z.Total, z.expiry; FROM (dbclocation+[CashSale]) x LEFT join (dbclocation+[ACCOUNTS]) Y ON (x.customer=y.accountid) ; LEFT JOIN (dbclocation+[Cashdata]) z ON (x.transid=z.transid) LEFT join (dbclocation+[itemmast]) a ON (z.itemid=a.itemid) ; LEFT JOIN (dbclocation+[accounts]) d ON (x.depositid=d.accountid); WHERE x.transid=invnum ; Order By z.transid, x.Date,z.sr_no ; INTO cursor ([printinvoice]) readwrite ELSE Select d.name as deposited,x.depositid, x.Total As PrdTotal, '' as fbrinv, '' as fbrPOST, x.daysrno, x.discount As prdDisc, x.memdisc,; 0 as TAXPRATE, 0 as TAXRATE, x.Payment,; x.EXPAMT, x.transid, x.name As Memo,Space(9) As bill,; x.Date,x.ddate,x.address1,x.address2,x.SaleMan,x.customer,z.SaleMan As ySaleMan,Y.ac,Y.Name,Y.phone, Y.fax,y.accountid, ; z.ItemID, z.Batch, z.Desc, z.sr_no, z.packing, z.qty,z.bonus,z.rate,a.cost, a.trade ,x.dtime,x.srvchgs, z.discount, z.Total, z.expiry; FROM (dbclocation+[CashSale]) x LEFT join (dbclocation+[ACCOUNTS]) Y ON (x.customer=y.accountid) ; LEFT JOIN (dbclocation+[Cashdata]) z ON (x.transid=z.transid) LEFT join (dbclocation+[itemmast]) a ON (z.itemid=a.itemid) ; LEFT JOIN (dbclocation+[accounts]) d ON (x.depositid=d.accountid); WHERE x.transid=invnum ; Order By z.transid, x.Date,z.sr_no ; INTO cursor ([printinvoice]) readwrite endif thedeposited=deposited =changeFieldStruc() IF EMPTY(memo) AND depositid<>[019] replace ALL memo WITH thedeposited ENDIF XDISCLABEL=[] rept_saleman=[] SCAN replace cost WITH NVL(cost,0), trade WITH NVL(trade,0), sr_no WITH RECNO() IF discount<>0 XDISCLABEL=[DISC] ENDIF IF NOT EMPTY(saleman) rept_saleman=IIF(SEEK(saleman,[accounts],[accountid]),accounts.name,[]) endif endscan If xcompany.haspart PartsValue=0 partsQty=0 Select 'printinvoice' Go Top Scan If Seek(ItemID,'itemmast','itemid') And itemmast.ispart PartsValue=PartsValue+(rate*qty-discount) partsQty=partsQty+qty Scatter Name saveit Delete ENDIF IF discount<>0 XDISCLABEL=[DISC] endif Endscan If PartsValue<>0 Append Blank Gather Name saveit Replace Desc With 'REPAIR CHARGES',; qty With partsQty,; rate With (PartsValue)/partsQty,; total With PartsValue Endif Endif go top STORE 0 TO TOTALTAX, fbrservice, SERVICECHARGES, TOTALAMOUNT, PRODUCTDISCOUNT,; MEMBERDISCOUNT, NETAMOUNT, RECEIVEDAMOUNT, BALANCEAMOUNT IF type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv) fbrservice=1 endif SERVICECHARGES=srvchgs TOTALAMOUNT=ROUND(Printinvoice.prdtotal+printinvoice.srvchgs,0) PRODUCTDISCOUNT=prdDisc MEMBERDISCOUNT=memdisc netamount=ROUND(Printinvoice.prdtotal+fbrservice-Printinvoice.prdDISC-PRINTINVOICE.MEMDISC+printinvoice.srvchgs,0) RECEIVEDAMOUNT=iif(empty(payment),netamount,payment) BALANCEAMOUNT=RECEIVEDAMOUNT-netamount ************* %>

<>

<> <%if not empty(xcompany.fbrposid)%> <%endif%> <%if not empty(fbrnumberreceived)%> <%endif%>

<%if type([searchresults.fbrinv])=[C] and not empty(searchresults.fbrinv)%>

<<[POSID# ]+ALLT(xcompany.fbrposid)>> <<[FBR# ]+ALLT(fbrinv)>>

<%endif%> <%if not empty(memo)%>

<>

<%endif%>

<<[INV# ]+ALLT(TRANSID)+[ ]+ttoc(dtime)>>

<%SCAN%> <% ITEMTX=round(iif(empty(taxprate),taxrate*qty,(qty*rate)-(qty*rate)/(1+taxprate/100)),2) SALEINCLUDINGTAX=qty*rate saleexcludingtax=saleincludingtax-itemtx totaltax=totaltax+itemtx %> <%ENDSCAN%> <%if totaltax<>0 %> <%endif%> <%if fbrservice<>0 %> <%endif%> <%if SERVICECHARGES<>0 %> <%endif%> <%if round(PRODUCTDISCOUNT+MEMBERDISCOUNT,2)<>0 %> <%endif%>
# DETAILS PRICE QTY TAX AMOUNT
<> <> <> <> <> <>
TOTAL TAX<>
POS SERVICE CHARGES<>
SERVICE CHARGES<>
TOTAL AMOUNT<>
YOU SAVED <0>>

<<'OPERATOR '+ALLT(theuser)+' '+IIF(EMPTY(REPT_SALEMAN),'','SOLD BY: '+REPT_SALEMAN)>>

<%if NOT EMPTY(XCOMPANY.CUSTMSG1) %>

<>

<%endif%> <%if NOT EMPTY(XCOMPANY.CUSTMSG2) %>

<>

<%endif%> <%if NOT EMPTY(XCOMPANY.CUSTMSG3) %>

<>

<%endif%> <%if NOT EMPTY(XCOMPANY.CUSTMSG4) %>

<>

<%endif%>